:root {
  --key-size: min(4vw, 40px);
  --key-margin: min(0.3vw, 3px);
  --keyboard-padding: min(2vw, 20px);
  --border-radius: min(0.8vw, 8px);
}

.keyboard {
  margin: min(10vw, 100px) auto;
  width: auto;
  max-width: 90vw;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: nowrap;
  transition: all 0.3s ease;
  overflow-x: auto;
  padding: var(--keyboard-padding);
  scrollbar-width: none;
  -ms-overflow-style: none;
  white-space: nowrap;
}

.keyboard::-webkit-scrollbar {
  display: none;
}

/* 白天模式 - 简约古风 */
.keyboard.day-mode {
  background: #f5f5f5;
  border-radius: var(--border-radius);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  border: 1px solid #8b4513;
}

.keyboard.day-mode > span {
  display: inline-block;
  width: var(--key-size);
  height: var(--key-size);
  border: 1px solid #8b4513;
  text-align: center;
  line-height: var(--key-size);
  margin: var(--key-margin);
  background-color: #fff;
  color: #8b4513;
  border-radius: var(--border-radius);
  transition: all 0.3s ease;
  cursor: pointer;
  font-weight: 500;
  font-family: 'SimSun', serif;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.keyboard.day-mode > span:hover {
  background-color: #f0e6d2;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.keyboard.day-mode > span:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  background-color: #e6d9c3;
}

/* 黑夜模式 - 赛博朋克 */
.keyboard.night-mode {
  background: rgba(0, 0, 0, 0.9);
  border-radius: var(--border-radius);
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.2);
  border: 1px solid #00ffff;
}

.keyboard.night-mode > span {
  display: inline-block;
  width: var(--key-size);
  height: var(--key-size);
  border: none;
  text-align: center;
  line-height: var(--key-size);
  margin: var(--key-margin);
  background: linear-gradient(145deg, #1a1a1a, #2a2a2a);
  color: #00ffff;
  border-radius: var(--border-radius);
  transition: all 0.3s ease;
  cursor: pointer;
  font-weight: 500;
  font-family: 'Arial', sans-serif;
  text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
  flex-shrink: 0;
}

.keyboard.night-mode > span:hover {
  transform: translateY(-3px);
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

.keyboard.night-mode > span:active {
  transform: translateY(1px);
  box-shadow: 0 0 5px rgba(0, 255, 255, 0.2);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background 0.5s ease;
  padding: min(2vw, 20px);
}

body.day-mode {
  background: #f5f5f5;
}

body.night-mode {
  background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
}

canvas {
  display: block;
  margin: min(1vw, 10px) auto;
  width: min(90vw, 900px);
  height: auto;
}

.words {
  color: #7f8483;
  width: min(30vw, 300px);
  height: min(20vw, 200px);
  position: fixed;
  top: 0;
  left: 0;
  overflow: scroll;
  background-color: #0d0d0d;
  font-size: min(1.4vw, 14px);
  letter-spacing: min(0.3vw, 3px);
}

footer {
  position: fixed;
  bottom: min(1vw, 10px);
  right: min(1vw, 10px);
  color: #ccc;
  transition: color 0.3s ease;
  font-size: min(1vw, 12px);
}

body.day-mode footer {
  color: #8b4513;
}

/* 模式切换按钮样式 */
.mode-switch {
  position: fixed;
  top: min(2vw, 20px);
  right: min(2vw, 20px);
  padding: min(1.2vw, 12px) min(2.4vw, 24px);
  background: #fff;
  color: #8b4513;
  border: 1px solid #8b4513;
  border-radius: var(--border-radius);
  cursor: pointer;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  font-weight: 500;
  letter-spacing: min(0.1vw, 1px);
  font-family: 'SimSun', serif;
  display: flex;
  align-items: center;
  gap: min(0.8vw, 8px);
  font-size: min(1vw, 14px);
}

body.night-mode .mode-switch {
  background: linear-gradient(145deg, #1a1a1a, #2a2a2a);
  color: #00ffff;
  border: 1px solid #00ffff;
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.1);
}

.mode-switch:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
  background-color: #f0e6d2;
}

body.night-mode .mode-switch:hover {
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
}

.mode-switch:active {
  transform: translateY(1px);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  background-color: #e6d9c3;
}

body.night-mode .mode-switch:active {
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.1);
}

.mode-icon {
  font-size: min(1.2vw, 16px);
}

/* 响应式布局调整 */
@media screen and (max-width: 768px) {
  .keyboard {
    max-width: 95vw;
  }

  .keyboard > span {
    width: calc(var(--key-size) * 0.9);
    height: calc(var(--key-size) * 0.9);
    line-height: calc(var(--key-size) * 0.9);
  }
}

@media screen and (max-width: 480px) {
  .keyboard {
    max-width: 100vw;
  }

  .keyboard > span {
    width: calc(var(--key-size) * 0.8);
    height: calc(var(--key-size) * 0.8);
    line-height: calc(var(--key-size) * 0.8);
    margin: 1vw;
  }
}
